home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 6 / The Arsenal Files 6 (Arsenal Computer).ISO / os2bbs / ftpfid16.zip / FTPFID16.CMD < prev    next >
OS/2 REXX Batch file  |  1996-02-22  |  27KB  |  901 lines

  1. /* FTPFIDO.CMD - rexx script to get FidoNet mail via FTP */
  2.  
  3. /*------------------------------------------------------------------
  4.  * Version 1.6 by Jerry Gause 1:3651/9
  5.  * Many thanks go to John Souvestre for the original base code
  6.  * and of course to Patrick J. Mueller & Cliff Nadler for RxFtp.
  7.  * Change global variables below to suit your system.
  8.  * Change lines marked with "CFP!!!" to suit your provider.
  9.  * Important!!!!!!!!!!!!!
  10.  * Dlls needed for this script are: RxFtp, Rexxutil and Rexxlib.
  11.  * Rxftp is included in it's own archive.
  12.  * If using OS/2 2.X be sure to use the Rxftp32.Dll renamed
  13.  * to Rxftp.dll.
  14.  * Rexxlib was not included because it's shareware.
  15.  * You can freq it from me as Rexxlb.Zip.
  16.  * This is tailored for a Binkley style outbound. For FD style outbounds 
  17.  * you need to set the "fd" verb below and "arcname" must point to
  18.  * the arcmail bundles destined for your uplink.
  19.  * You also need to setup a seperate Binkley style outbound  
  20.  * and use something like SQUISH to pack out netmail.
  21.  * I have made many changes to the original code including much more
  22.  * mailer-like operation. I simply truncate the file the same way Bink would.
  23.  * Lot's of error checking and logging of errors as well as normal
  24.  * operation. If anything goes wrong, it is logged and the session
  25.  * is aborted. 
  26.  *------------------------------------------------------------------*/
  27.  
  28. '@echo off'
  29. host = "ftp.sstar.com"
  30. name = ""
  31. password = ""
  32. seqfile  = 'f:\bbs\ftpfido.seq'
  33. fd = 0  /* Set to 1 to enable the FD mode */
  34. arcname = '??????.*' /* Arcmail bundles  FD only */
  35. inbound = 'd:\ftpin2'   /* Binkley or FD secure inbound */
  36. ftpin = 'd:\ftpin' /* Inbound for FTP */
  37. errlog = 'f:\bbs\logs\error.log' /* a logfile for errors */
  38. bsy = 'f:\binkley\IHUB.BSY'      /* local file sent as remote busy flag */
  39. remotebsyname = 'IHUB.BSY'    /* remote name for above */
  40. avbps = 2000 /* Your average bps rate */
  41. flg = 'f:\bbs\logs\Doing_ftp.flg' /* process flag */
  42. logfile  = 'F:\bbs\logs\ftpfido.log' /* Drive containing logs */
  43. listfile  = 'F:\bbs\logs\ftplist.log'
  44. mailbundle = 'd:\ftpin\f349fff8.*' /* I only move mailbundles from ftpin to inbound. Change to *.* if you move all */
  45. ndyet = 'd:\ftpin\ndyet.flg' /* Use this flag to prevent Allfix from running to prevent tics w/o files and vice versa */
  46. tcpbin = 'd:\tcpip\bin' /* where hangup.cmd is located to terminate slip session */
  47. hangup = 1  /* whether to hangup or not */
  48. scrlgth = 25
  49.  
  50. /* netout is only used in FD mode to send netmail that has been packed Bink style. */
  51. netout = 'f:\' /* Binkley style outbound for sending netmail in FD mode. */
  52. outbound = 'f:\binkley\outbound' /* normal mailer outbound */
  53. fidosite = '018c0001' /* 396/1 In hex for Binkley bsy flags and hlo files */
  54. fidobsy  = fidosite'.bsy'
  55. fidohold = fidosite'.hlo'
  56. pktname = fidosite'.hut' /* Only hold mail is handled */ 
  57. newname = fidosite'.pkt' /* Remote file name */
  58.  
  59. 'mode co80,'||scrlgth
  60.  
  61. bttm2 = scrlgth - 2
  62. bttm3 = scrlgth - 3
  63.  
  64. total_received = 0
  65. total_sent = 0
  66. total_uls = 0
  67. total_files = 0
  68. sizethere = 0
  69. howmucht = 0
  70. howlongt = 0
  71.  
  72. UpperCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  73. LowerCase = 'abcdefghijklmnopqrstuvwxyz'
  74.  
  75. Signal on Syntax Name ErrorStop
  76. Signal on Halt Name Abort
  77. Signal on Failure Name FailureStop
  78.  
  79. rc = stream(logfile,'C','open write')
  80.  
  81. call Lineout logfile ,date('N') Time('N') 'FTPFIDO starting up.'
  82.  
  83. Call SysCurState Off
  84. Call CopyInfo
  85.  
  86. if RxFuncQuery("FtpLoadFuncs") then
  87.    do
  88.    rc = RxFuncAdd("FtpLoadFuncs","RxFtp","FtpLoadFuncs")
  89.    rc = FtpLoadFuncs(quiet)
  90.    end
  91.  
  92. if RxFuncQuery("SysLoadFuncs") then
  93.    do
  94.    rc = RxFuncAdd("SysLoadFuncs","RexxUtil","SysLoadFuncs")
  95.    rc = SysLoadFuncs()
  96.    end
  97.  
  98. if RxFuncQuery("rexxlibregister") then
  99.    do
  100.    rc = RxFuncAdd('rexxlibregister','rexxlib','rexxlibregister')
  101.    rc = rexxlibregister()
  102.    end
  103.  
  104. /* Check the busy flag */
  105. New=Directory(outbound)
  106. IF Stream(fidobsy,'C', 'Query Exists') <>' ' Then
  107.     Do
  108.   say '!Tosser Busy - Not this time...'
  109. rc = lineout(logfile,'!Tosser Busy - Not this time.')
  110.   signal exit
  111.     end
  112. else
  113.  do
  114.  rc= doscreat(fidobsy) /* Set local busy flag */
  115. if rc <> 1 Then
  116.     Do
  117.   say '!Error creating busy flag.'
  118. rc = lineout(logfile,'!Error creating busyflag.')
  119.   signal exit
  120.     end
  121.  end
  122.  
  123. IF Stream(flg,'C', 'Query Exists') <>' ' Then
  124.     Do
  125.   say '!Must be running already.'
  126. rc = lineout(logfile,' Must be running already.')
  127. New=Directory(outbound)
  128. 'del 'fidobsy '> nul: 2>&1'
  129.  IF rc <> 0 Then
  130.   Do
  131.   say '!Error deleting 'fidobsy''
  132.   rc = lineout(logfile,'!Error deleting 'fidobsy)
  133.   end
  134.  signal exit
  135.     end
  136. else
  137.  do
  138. rc=doscreat(flg) /* Set process flag */
  139. IF rc <> 1 Then
  140.     Do
  141.   say '!Error creating flagfile.'
  142. rc = lineout(logfile,'!Error creating flagfile.')
  143.   signal exit
  144.     end
  145.  end
  146.  
  147. if hangup = 1 then do
  148. New = Directory(tcpbin)
  149. 'start /fs /c /b hangup.cmd 'killme
  150. end
  151.  
  152. killme = DosPid()
  153.     Call SysCurPos 0,21
  154.     say 'Process id: 'killme  'Begin: 'Time('N')''
  155.  
  156. /* Get the latest send sequence*/
  157. seqstr = "0123456789abcdefghijklmnopqrstuvwxyz"
  158. daywk = "mo tu we th fr sa su"
  159.  
  160. /* Contains the day and sequence*/
  161. IF Stream(seqfile,'C', 'Query Exists') <>' ' Then
  162.   Do
  163.   line = LINEIN(seqfile)
  164.   day = WORD(line, 1)
  165.   if POS(day, daywk) = 0 then
  166.     day = "mo"
  167.   seq = WORD(line, 2)
  168.   seqno = POS(seq, seqstr)
  169.   if seqno = 0 then do
  170.     seq = "0"
  171.     seqno = 1
  172.   end
  173.  end
  174. else do
  175.   file = LINEOUT(seqfile, 'mo 0')
  176.   seqno = 1
  177. end
  178. file = LINEOUT(seqfile)
  179.  
  180. rc = FtpSetBinary('Binary')
  181.  
  182. /*------------------------------------------------------------------
  183.  * LOGON
  184.  *------------------------------------------------------------------*/
  185.  
  186. rc = FtpSetUser(host, name, password) 
  187.  
  188. stime = time('e')
  189.  
  190. attached = FtpSys(siteinfo)
  191. Call SysCurPos 1,21
  192. say ''attached ''
  193. len = length(attached)
  194. if len > 8 then                                               /* CFP!!! */
  195. do
  196.     Call SysCurPos 2,21
  197.     rc = lineout(logfile,' Login successful')
  198.     say 'Login successful '
  199.     Call datetime
  200.  
  201.     rc = FtpChDir('..')                                         /* CFP!!! */
  202.  
  203.     rc = FtpPut(bsy,remotebsyname)
  204.     if err <> -1 & FTPERRNO <> '0' then
  205.     do
  206.     say '!Error putting busy flag on remote.'
  207.     rc = lineout(logfile,'!Error putting busy flag on remote.')
  208.     signal abort
  209.     end
  210.  
  211. /*------------------------------------------------------------------
  212.  * Change to remote inbound directory.
  213.  *------------------------------------------------------------------*/
  214.  
  215.     rc = FtpChDir("in")                                      /* CFP!!!! */
  216.     if err <> -1 & FTPERRNO <> '0' then
  217.     do
  218.     say '!Error changing directory on remote.'
  219.     rc = lineout(logfile,'!Error changing directory on remote.')
  220.     signal abort
  221.     end
  222.  
  223. /*------------------------------------------------------------------
  224.  * Send Raw Packets
  225.  *------------------------------------------------------------------*/
  226.  
  227. if fd = 1 then 
  228. New=Directory(netout)
  229. else
  230. New=Directory(outbound)
  231.  
  232. p = 5
  233.  
  234. rc = SysFileTree(pktname,files.,"F")
  235. if files.0 > 0 then
  236.   do
  237.     Call datetime
  238.       filename = filespec("name", word(files.1,5))
  239.        Trunc = 0
  240.        Nuke = 1
  241.        Call Put filename word(files.1,5) word(files.1,3) newname
  242.        p = p + 1
  243.   end
  244.  
  245. /*------------------------------------------------------------------
  246.  * Send Mail Bundles and files
  247.  *------------------------------------------------------------------*/
  248.  
  249. IF Stream(fidohold,'C', 'Query Exists') <>' ' Then
  250.  Do
  251.   do until LINES(fidohold) = 0
  252.     Call datetime
  253.  
  254.       ennd = scrlgth - 4
  255.       if p > ennd then do
  256.         p = ennd
  257.         do until p = 5
  258.         Call SysCurPos p,0
  259.         say "                                                  "
  260.         p = p - 1
  261.         end /* do until */
  262.        end
  263.  
  264.     line = LINEIN(fidohold)
  265.     /* Get the file name out of the path ect*/
  266.     posfile = LASTPOS('\', line) + 1
  267.     filename = SUBSTR(line, posfile)
  268.  
  269.    Select
  270.  
  271.      When Pos('^', line) = 1 then
  272.       Do
  273.      fullname = strip(line,l,'^')
  274.       rc = SysFileTree(fullname,outfile.,"F")
  275.       IF Stream(fullname,'C', 'Query Exists') <>' ' Then
  276.        Do
  277.       Trunc = 0
  278.       Nuke = 1       
  279.       Call Put filename word(outfile.1,5) word(outfile.1,3) filename
  280.        end
  281.        else do
  282.        p = p + 1
  283.          Call SysCurPos p,0
  284.        say '!'fullname' not found .'
  285.        rc = lineout(logfile,'!'fullname' not found.')
  286.         end
  287.       end
  288.  
  289.      When Pos('#', line) = 1 then
  290.        Do
  291.        fullname = strip(line,l,'#')
  292.     rc = SysFileTree(fullname,outfile.,"F")
  293.       IF Stream(fullname,'C', 'Query Exists') <>' ' & word(outfile.1,3) <> 0 Then
  294.     Do
  295.     /* Make sure the sequence is correct*/
  296.     posfile = LASTPOS('.', filename) + 1
  297.     setseq = SUBSTR(filename, posfile)
  298.     fday = TRANSLATE(DELSTR(setseq, 3))
  299.     fseq = TRANSLATE(SUBSTR(setseq, 3, 1))
  300.     fseqno = POS(fseq, seqstr)
  301.  
  302.     /* Check if the days match*/
  303.     if day = fday then 
  304.       do
  305.     if fseqno > seqno then 
  306.         do
  307.       seqno = fseqno
  308.       seq = SUBSTR(seqstr, seqno, 1)
  309.         end
  310.       end
  311.        else do
  312.        day = fday
  313.        seqno = fseqno
  314.        if seqno = 0 then seqno = 1
  315.        seq = SUBSTR(seqstr, seqno, 1)
  316.         end
  317.  
  318.       remfile1 = DELSTR(filename, posfile)||day||seq
  319.  
  320.       Trunc = 1
  321.       Nuke = 0       
  322.  
  323.       Call Put filename word(outfile.1,5) word(outfile.1,3) remfile1
  324.       
  325.         /* Update the sequence file*/
  326.         'erase 'seqfile
  327.         seqno = seqno + 1
  328.         seq = SUBSTR(seqstr, seqno, 1)
  329.         file = LINEOUT(seqfile, day' 'seq)
  330.         file = LINEOUT(seqfile)
  331.     end
  332.        else do
  333.        p = p + 1
  334.        Call SysCurPos p,0
  335.        say '!'fullname' not found or 0 length.'
  336.        rc = lineout(logfile,'!'fullname' not found or 0 length.')
  337.         end
  338.        end
  339.  
  340.     otherwise
  341.        Do
  342.       IF Stream(line,'C', 'Query Exists') <>' ' Then
  343.     Do
  344.       rc = SysFileTree(line,outfile.,"F")
  345.       Trunc = 0
  346.       Nuke = 0       
  347.       Call Put filename word(outfile.1,5) word(outfile.1,3) filename
  348.     end
  349.        else do
  350.        p = p + 1
  351.        Call SysCurPos p,0
  352.        say '!'fullname' not found .'
  353.        rc = lineout(logfile,'!'fullname' not found.')
  354.         end
  355.        end
  356.    end /* Select */
  357.    p = p + 1
  358.   end /* Do Until */
  359.    rc = stream(fidohold,'C','close')
  360.    'del 'fidohold '> nul: 2>&1'
  361.     IF rc <> 0 Then
  362.     Do
  363.     p = p + 1
  364.     Call SysCurPos p,0
  365.     say '!Error deleting 'fidohold''
  366.     rc = lineout(logfile,'!Error deleting 'fidohold)
  367.     end
  368.  end /* Do */
  369. if sizethere = '0' then
  370.  do
  371.  Call SysCurPos p,0
  372.  say ' No mail to send at this time.'
  373.  rc = lineout(logfile,' No mail to send at this time')
  374.    p = p + 1
  375.  end
  376.  
  377. /*------------------------------------------------------------------
  378.  * Send FD Mail Bundles
  379.  *------------------------------------------------------------------*/
  380.  
  381. if fd = 1 then
  382. do
  383. New=Directory(outbound)
  384.  
  385.     rc = SysFileTree(arcname,outfile.,"F")
  386.     if outfile.0 > 0 then
  387.     do
  388.         sizethere = 0
  389.     x = 1
  390.     do outfile.0    /* loop through all the files here */
  391.          Call datetime
  392.  
  393.           ennd = scrlgth - 4
  394.           if p > ennd then do
  395.             p = ennd
  396.             do until p = 5
  397.             Call SysCurPos p,0
  398.             say "                                                  "
  399.             p = p - 1
  400.             end /* do until */
  401.            end
  402.  
  403.         filename = filespec("name", word(outfile.x,5))
  404.         fullname = word(outfile.x,5)
  405.         if filename <> '' & LENGTH(filename) > 3 & word(outfile.x,3) <> 0 then
  406.         do
  407.             /* Make sure the sequence is correct*/
  408.         posfile = LASTPOS('.', filename) + 1
  409.         setseq = SUBSTR(filename, posfile)
  410.         fday = TRANSLATE(DELSTR(setseq, 3))
  411.         fseq = TRANSLATE(SUBSTR(setseq, 3, 1))
  412.         fseqno = POS(fseq, seqstr)
  413.  
  414.         /* Check if the days match*/
  415.         if day = fday then 
  416.           do
  417.         if fseqno > seqno then 
  418.             do
  419.           seqno = fseqno
  420.           seq = SUBSTR(seqstr, seqno, 1)
  421.             end
  422.           end
  423.            else do
  424.            day = fday
  425.            seqno = fseqno
  426.            if seqno = 0 then seqno = 1
  427.            seq = SUBSTR(seqstr, seqno, 1)
  428.             end
  429.  
  430.              remfile1 = DELSTR(filename, posfile)||day||seq
  431.  
  432.            Trunc = 1
  433.            Nuke = 0    
  434.  
  435.            Call Put filename fullname word(outfile.x,3) remfile1
  436.  
  437.         /* Update the sequence file*/
  438.         'erase 'seqfile
  439.         seqno = seqno + 1
  440.         seq = SUBSTR(seqstr, seqno, 1)
  441.         file = LINEOUT(seqfile, day' 'seq)
  442.         file = LINEOUT(seqfile)
  443.             end
  444.            else
  445.           do
  446.           say '!'fullname' not found or 0 length.'
  447.           rc = lineout(logfile,'!'fullname' not found or 0 length.')
  448.           end
  449.        x = x + 1
  450.        p = p + 1
  451.     end /* Do loop */
  452.     end
  453.     if sizethere = '0' then
  454.     do
  455.     say ' No echomail to send at this time.'
  456.     rc = lineout(logfile,' No echomail to send at this time')
  457.         p = p + 1
  458.     end
  459. end
  460.  
  461. /*------------------------------------------------------------------
  462.  * Change to remote outbound directory.
  463.  *------------------------------------------------------------------*/
  464.  
  465.     rc = FtpChDir("..")                                 /* CFP!!!! */
  466.     if err <> -1 & FTPERRNO <> '0' then
  467.     do
  468.     say '!Error changing directory on remote.'
  469.     rc = lineout(logfile,'!Error changing directory on remote.')
  470.     signal abort
  471.     end
  472.     rc = FtpChDir("out")                                /* CFP!!!! */
  473.     if err <> -1 & FTPERRNO <> '0' then
  474.     do
  475.     say '!Error changing directory on remote.'
  476.     rc = lineout(logfile,'!Error changing directory on remote.')
  477.     signal abort
  478.     end
  479.  
  480.  
  481. /*------------------------------------------------------------------
  482.  * Get Mail and Files
  483.  *------------------------------------------------------------------*/
  484.  
  485.     New=Directory(ftpin)
  486.     rc = Ftpdir('*.*',infile.)  /* get list of files there for list */
  487.       if infile.0 > 0 & rc = 0 then
  488.    do
  489.       y = 0
  490.       'del 'listfile '> nul: 2>&1'
  491.       rc = stream(listfile,'C','open write')
  492.        total_bytes = 0
  493.        do i = 1 to infile.0
  494.     filename = word(infile.i,9)
  495.     size = word(infile.i,5)
  496.     total_bytes = total_bytes + size
  497.     rc = LINEOUT(listfile, filename size)
  498.         if y < bttm2 then do
  499.     Call SysCurPos y,55
  500.     say ''filename' -' size''
  501.         end 
  502.         y = y + 1
  503.        end
  504.     rc = stream(listfile,'C','close')
  505.     apxsecs = total_bytes%avbps
  506.     apxmins = apxsecs%60
  507.         bttm3 = scrlgth - 3
  508.     Call SysCurPos bttm3,0
  509.     say ' Receiving 'infile.0  'file(s) 'total_bytes' bytes 'apxmins' avg. mins.'
  510.     rc = lineout(logfile,' Receiving 'infile.0 'file(s) 'total_bytes' bytes 'apxmins' avg. mins.')
  511.     bps = 2000
  512.     x = 1                       /* reset the pointer */
  513.  
  514.     /* time to get files here from There */
  515.      do infile.0
  516.  
  517.      Call datetime
  518.  
  519.       ennd = scrlgth - 4
  520.       if p > ennd then do
  521.         p = ennd
  522.         do until p = 5
  523.         Call SysCurPos p,0
  524.         say "                                                  "
  525.         p = p - 1
  526.         end /* do until */
  527.        end
  528.  
  529.         filename = word(infile.x,9)
  530.  
  531.             if filename = "incoming" then  x = x + 1  /* CFP!!!! */
  532.             if filename = "incoming" then iterate    /* CFP!!!! */  
  533.  
  534.         Call Get filename word(infile.x,5)
  535.  
  536.     x = x + 1
  537.     p = p + 1
  538.      end /* Do loop */
  539.  end
  540.     else
  541.     do
  542.         Call SysCurPos p,0
  543.     rc = lineout(logfile,' No files to get')
  544.     say ' No files to get.'
  545.     end
  546.  
  547. /*------------------------------------------------------------------
  548.  * Change to remote root directory and remove busy flag.
  549.  *------------------------------------------------------------------*/
  550.  
  551.     rc = FtpChDir('..')
  552.     if err <> -1 & FTPERRNO <> '0' then
  553.     do
  554.     say '!Error changing directory on remote.'
  555.     rc = lineout(logfile,'!Error changing directory on remote.')
  556.     end
  557.     rc = FtpDelete(remotebsyname)
  558.     if err <> -1 & FTPERRNO <> '0' then
  559.     do
  560.     say '!Error deleting busy flag from remote.'
  561.     rc = lineout(logfile,'!Error deleting busy flag from remote.')
  562.     end
  563.  
  564.     signal done
  565.  
  566. end /* Login loop */
  567. else
  568. do
  569. Call SysCurPos 1,28
  570.     say '!Login failed... session aborted'
  571.     rc = lineout(logfile,'!Login failed... session aborted')
  572.     signal abort
  573. end
  574.  
  575.  
  576. /*------------------------------------------------------------------
  577.  * SubRoutines
  578.  *------------------------------------------------------------------*/
  579.  
  580. DateTime:
  581.     Call SysCurPos 3,21
  582.     say ''date('N') Time('N')''
  583. Return
  584.  
  585. /*------------------------------------------------------------------
  586.  * PUT
  587.  *------------------------------------------------------------------*/
  588.  
  589. Put:
  590. parse arg filehere fullname sizehere filethere
  591. o = 1
  592.  
  593. Call SysCurPos p,0
  594.  
  595. filethere = translate(filethere, LowerCase, UpperCase)
  596. if filehere <> filethere then
  597.  do
  598.    rc = lineout(logfile,' sending 'fullname '- 'sizehere 'bytes as 'filethere)
  599.    say ' Sending 'filehere ' - 'sizehere' bytes as 'filethere''
  600.  end
  601. else
  602.   do
  603.     rc = lineout(logfile,' sending 'fullname '- 'sizehere 'bytes')
  604.     say ' Sending 'filehere ' - 'sizehere' bytes '
  605.   end
  606.  
  607.   ustart = time('e')
  608.       
  609.   err = FtpPut(fullname, filethere, 'binary')
  610.  
  611.   uelapsed = time('e')
  612.  
  613.   howmuch = strip(uelapsed-ustart,,0)
  614.   bps = strip(format(sizehere/howmuch,10,0))
  615.         
  616.   if err = -1 & FTPERRNO = '0' then
  617.   do
  618.   /* add code to  test for good transfer by filesize */
  619.     rc = FtpDir(filethere,test.)     /* get size from remote */
  620.     if test.0 = 1 then /* it did get there  */
  621.      do
  622.     sizethere = word(test.1,5)
  623.      if sizehere = sizethere then /* if the same size, delete or truncate if necessary */
  624.       do
  625.       p = p + 1
  626.       Call SysCurPos p,0
  627.       total_sent = total_sent + sizethere /* get size for report */
  628.        howmucht = howmucht + howmuch
  629.            total_uls = total_uls + 1
  630.        Select
  631.         When Trunc = 1 then
  632.         do  
  633.         rc = lineout(logfile,' Successful - Truncating 'filehere)
  634.         say ' Truncating 'filehere''
  635.         rc=doscreat(fullname)
  636.         IF rc <> 1 Then
  637.           do
  638.         say '!Error truncating 'fullname''
  639.         rc = lineout(logfile,'!Error truncating 'fullname
  640.         signal abort
  641.           end
  642.         end
  643.         When Nuke = 1 then
  644.         do  
  645.         rc = lineout(logfile,' Successful - Deleting 'fullname)
  646.         say ' Deleting 'fullname''
  647.         rc = SysFileDelete(fullname)
  648.         IF rc <> 0 Then
  649.           do
  650.         say '!Error deleting 'fullname''
  651.         rc = lineout(logfile,'!Error deleting 'fullname
  652.         signal abort
  653.           end
  654.         end
  655.        otherwise
  656.        end /* Select */
  657.         p = p + 1
  658.         Call SysCurPos bttm2,0
  659.         say "                                                  "
  660.     Call SysCurPos bttm2,0
  661.     say ' Sent 'total_uls 'file(s) 'total_sent 'bytes 'howmucht%60 'min. 'strip(format(howmucht//60,3,0)) 'secs.'
  662.         Call SysCurPos p,0
  663.         say 'Sent 'filehere '- 'howmuch%60 'min. 'strip(format(howmuch//60,3,0)) 'secs. 'bps 'bps.'
  664.         rc = lineout(logfile,' sent 'filehere' - 'howmuch%60 'min. 'strip(format(howmuch//60,3,0)) 'secs. Baud = 'bps)
  665.       end /* size */
  666.     else
  667.       do
  668.         rc = lineout(logfile,'!Error in size - Deleting  'filethere 'from inbound')
  669.         say '!Error in size - Deleting  'filethere 'from inbound'
  670.         rc = FtpDelete(filethere)
  671.         if err <> -1 & FTPERRNO <> '0' then
  672.         do
  673.         say '!Error deleting 'filethere 'from remote.'
  674.         rc = lineout(logfile,'!Error deleting 'filethere 'from remote.')
  675.         signal abort
  676.         end
  677.       end
  678.      end /* test */
  679.     else
  680.        do
  681.        say '!Error in filetest'
  682.     rc = lineout(logfile,'!Error in filetest!')
  683.        signal xabort
  684.        end
  685.   end
  686.   else
  687.    do
  688.     say '!FTP returned error 'FTPERRNO''
  689.     rc = lineout(logfile,'!FTP returned error 'FTPERRNO)
  690.     signal xabort
  691.     end
  692.  
  693. Return
  694.  
  695. /*------------------------------------------------------------------
  696.  * GET
  697.  *------------------------------------------------------------------*/
  698.  
  699. Get:
  700. parse arg filename filesize
  701.  
  702. Call SysCurPos p,0
  703.  
  704.         say ' Recieving 'filename '- ' filesize 'bytes '
  705.         start = time('e')
  706.         err = FtpGet(filename, filename,"binary")    /* Transfer the file */
  707.         elapsed = time('e')
  708.  
  709.         if err = -1 & FTPERRNO = '0' then
  710.          do
  711.              sizehere = stream(filename,'C','query size')    /* get the filesize here */
  712.              if sizehere = filesize then
  713.               do
  714.             Call SysCurPos p,0
  715.         say "                                                  "
  716.             Call SysCurPos p,0
  717.         howlong = strip(elapsed-start,,0)
  718.         bps = strip(format(sizehere/howlong,10,0))
  719.         say 'Recieved 'filename '- 'howlong%60 'min. 'strip(format(howlong//60,3,0)) 'secs. 'bps 'bps.'
  720.         rc = lineout(logfile,' received 'filename' - 'sizehere' - 'howlong%60 'min. 'strip(format(howlong//60,3,0)) 'secs. Baud = 'bps)
  721.         total_received = total_received + sizehere
  722.         total_files = total_files + 1
  723.         rc = FtpDelete(filename)
  724.         if err <> -1 & FTPERRNO <> '0' then
  725.         do
  726.         say '!Error deleting 'filename 'from remote.'
  727.         rc = lineout(logfile,'!Error deleting 'filename 'from remote.')
  728.         end
  729.         Call SysCurPos bttm2,0
  730.         say "                                                  "
  731.         Call SysCurPos bttm2,0
  732.                 howlongt = howlongt + howlong
  733.         say ' Received 'total_files 'file(s) 'total_received 'bytes 'howlongt%60 'min. 'strip(format(howlongt//60,3,0)) 'secs.'
  734.         if bps < 500 & filesize > 50000 then
  735.         do
  736.         say '!Something ain''t right!! too slow??'
  737.         rc = lineout(logfile,'!Something went wrong with bps')
  738.         signal abort
  739.         end
  740.               end /* size */
  741.              else
  742.              do
  743.          say '!Error in filesize'
  744.          rc = lineout(logfile,'!Error in filesize')
  745.              x = x - 1
  746.          end
  747.          end
  748.         else 
  749.         do
  750.         say '!FTP returned error 'FTPERRNO''
  751.         rc = lineout(logfile,'!FTP returned error 'FTPERRNO)
  752.             signal xabort
  753.         end
  754.  
  755. Return
  756.  
  757. /*------------------------------------------------------------------
  758.  * Aborts
  759.  *------------------------------------------------------------------*/
  760.  
  761. Xabort:
  762. Call SysCurPos p,0
  763. say '!File transfer failed..'
  764. rc = lineout(logfile,'!File transfer failed..')
  765.  
  766. Abort:
  767. Call SysCurPos 3,28
  768. say '!Session Aborted'
  769. rc = lineout(logfile,'!Session Aborted')
  770.  
  771.  rc= doscreat(ndyet)
  772. if rc <> 1 Then
  773.     Do
  774.    say '!Error creating ndyet flag.'
  775.    rc = lineout(logfile,'!Error creating ndyet flag.')
  776.     end
  777.  
  778.     rc = FtpChDir('..')
  779.     rc = FtpDelete(remotebsyname)
  780.  
  781. signal Abort1
  782.  
  783. /*------------------------------------------------------------------
  784.  * DONE
  785.  *------------------------------------------------------------------*/
  786.  
  787. Done:
  788.  
  789. IF Stream(mailbundle,'C', 'Query Exists') <>' ' Then
  790.  do
  791.  New=Directory(inbound)
  792.  copy ftpin||'\*.* > nul: 2>&1'
  793.  del ftpin||'\*.* /N > nul: 2>&1'
  794.  end
  795.  
  796. /* 'echo mailproc | rxqueue mailproc' ------This triggers my mailtosser */
  797.  
  798. Abort1:
  799.  
  800.     rc = FtpSetUser("X","X","X")
  801.     rc = FtpLogoff()
  802.     rc = FtpDropFuncs()
  803.  
  804. Call SysCurPos bttm3,0
  805. Say "                                                                               "
  806. Call SysCurPos bttm2,0
  807. Say "                                                                               "
  808. Call SysCurPos bttm3,0
  809.  
  810. etime = time('e')
  811.  
  812. say ' Sent 'total_sent 'bytes, received 'total_received 'bytes in 'etime%60 'minutes, 'strip(format(etime//60,6,0)) 'seconds.'
  813. rc = lineout(logfile, ' $Sent 'total_sent 'bytes, received 'total_received 'bytes in 'etime%60 'minutes, 'strip(format(etime//60,10,0)) 'seconds.' )
  814. if total_sent > 0 then
  815. do
  816. say ' Total u/l time - 'howmucht%60 'min. 'strip(format(howmucht//60,3,0))' secs.  'strip(format(total_sent/howmucht,10,0))' avg. u/l bps.'
  817. rc = lineout(logfile, ' Total u/l time - 'howmucht%60 'min. 'strip(format(howmucht//60,3,0))' secs.  'strip(format(total_sent/howmucht,10,0))' avg. u/l bps.')
  818. end
  819. if total_received > 0 then
  820. do
  821. say ' Total d/l time - 'howlongt%60 'min. 'strip(format(howlongt//60,3,0))' secs.  'strip(format(total_received/howlongt,10,0))' avg. d/l bps.'
  822. say ' Sent 'total_uls 'files(s) Received 'total_files 'file(s).'
  823. rc = lineout(logfile, ' Total d/l time - 'howlongt%60 'min. 'strip(format(howlongt//60,3,0))' secs.  'strip(format(total_received/howlongt,10,0))' avg. d/l bps.')
  824. rc = lineout(logfile, ' Sent 'total_uls 'file(s) Received 'total_files 'file(s).')
  825. end
  826.  
  827.       /* Clearing Local bsy Flag*/
  828.     New=Directory(outbound)
  829.     'del 'fidobsy '> nul: 2>&1'
  830.        IF rc <> 0 Then
  831.        Do
  832.        say '!Error deleting 'fidobsy''
  833.        rc = lineout(logfile,'!Error deleting 'fidobsy)
  834.        end
  835.  
  836.     /* remove process flag */
  837.       'del 'flg '> nul: 2>&1'
  838.        IF rc <> 0 Then
  839.        Do
  840.        say '!Error deleting 'flg''
  841.        rc = lineout(logfile,'!Error deleting 'flg)
  842.        end
  843.  
  844.     /* remove ndyet flag */
  845.      IF Stream(ndyet,'C', 'Query Exists') <>' ' Then
  846.       Do
  847.       'del 'ndyet' > nul: 2>&1'
  848.        IF rc <> 0 Then
  849.        Do
  850.        say '!Error deleting ndyet.flg'
  851.        rc = lineout(logfile,'!Error deleting ndyet.flg')
  852.        end
  853.       end
  854.  
  855. call Lineout logfile ,date('N') Time('N') 'FTPFIDO closing down.'
  856.  
  857. rc = stream(logfile,'C','close')
  858.  
  859. exit
  860.  
  861.  
  862. CopyInfo: Procedure
  863.  
  864. Call SysCls
  865.  
  866. Say '    ░░░░▒▒▒▒▓▓▓▓████'
  867. Say '      FTPFido'
  868. Say '   By Jerry Gause'
  869. Say 'Warped Software'
  870. Say '████▓▓▓▓▒▒▒▒░░░░    '
  871. Say ''
  872. Return
  873.  
  874. FailureStop:
  875. parse upper source tst
  876. tst=word(tst,3)
  877. tst=parsefn(tst)
  878. tst=word(tst,3)'.'word(tst,4)
  879.       say 'A Failure ('RC') has occurred on Line 'Sigl' in 'tst''
  880.       say 'ftpfido has Failure Exited'
  881.       call Lineout errlog ,date('N') Time('N') ':  ftpfido ,  A Failure ('RC') has occurred on Line 'Sigl' in 'tst
  882.    Signal Exit
  883.  
  884. ErrorStop:
  885. parse upper source tst
  886. tst=word(tst,3)
  887. tst=parsefn(tst)
  888. tst=word(tst,3)'.'word(tst,4)
  889.       say 'An Error ('RC') has occurred on Line 'Sigl' in 'tst''
  890.       say 'ftpfido has Error Exited'
  891.       call Lineout errlog ,date('N') Time('N') ':  ftpfido , An Error ('RC') has occurred on Line 'Sigl' in 'tst
  892.  
  893. exit:
  894. if hangup = 1 then do
  895. New = Directory(tcpbin)
  896. 'start /fs /c /b hangup.cmd 'killme
  897. end
  898. rc = stream(errlog,'C','close')
  899. rc = stream(logfile,'C','close')
  900. exit
  901.